﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace WTAppletProjectHTTPS.Models
{
    public enum TaskStatus
    {
        Pending,
        InProgress,
        Completed,
        Failed
    }

    public class ExcelTask
    {
        public string TaskId { get; set; }//任务ID
        public TaskStatus Status { get; set; }//任务状态
        public string FilePath { get; set; }//返回导出的Excel路径
        public string ErrorMessage { get; set; }//错误消息
        public double ProgressPercentage { get; set; }//进度百分比
    }

    public static class ExcelTaskQueue
    {
        public static ConcurrentDictionary<string, ExcelTask> Tasks = new ConcurrentDictionary<string, ExcelTask>();

        public static void ClearTask(string taskId)
        {
            try
            {
                if (ExcelTaskQueue.Tasks.TryRemove(taskId, out var task))
                {
                    // 删除生成的文件
                    //if (File.Exists(task.FilePath))
                    //{
                    //    File.Delete(task.FilePath);
                    //}
                }
            }
            catch (Exception)
            {

            }
           
        }
    }

}